package com.xbongbong.workflow.service.field;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.workflow.domain.entity.WorkflowNodeEntity;
import com.xbongbong.workflow.pojo.FilterCondition;
import com.xbongbong.workflow.pojo.WorkflowRulePojo;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author 吴峰
 * @date 2021/06/01 20:58
 */
@Service("abstractWorkflowConditionFieldService")
public abstract class AbstractWorkflowConditionFieldService  {


    public Object handlerFixedValue(FieldAttrEntity targetField, WorkflowNodeEntity workflowNodeEntity, FilterCondition workflowConditionPojo) throws XbbException {
        return workflowConditionPojo.getValue();
    }



    public Object handlerTargetFormField(Object object, PaasFormDataEntityExt paasFormDataEntity, JSONObject data, FieldAttrEntity fieldAttrEntity, FieldAttrEntity targetField, WorkflowNodeEntity workflowNodeEntity, WorkflowRulePojo workflowRulePojo, FilterCondition filterCondition) throws XbbException {
        if (Objects.isNull(object)) {
            object = data.get(fieldAttrEntity.getAttr());
        }
        return object;
    }
}
